<!DOCTYPE html>
<html lang="cmn-hans">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>计数器 vue2</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
  <style type="text/css">
    body{display:flex;justify-content:center;align-items:center;margin-top:40px}
    #counter{display:inline-flex;border:3px solid hsl(210,100%,50%);border-radius:20px;background-color:hsl(210,100%,50%);box-shadow:0 0 8px rgba(0,0,0,.4)}
    #counter button{display:inline-block;padding:0;margin:0;border:0;background-color:transparent;color:#fff;font-size:24px;width:32px;height:32px;outline:none}
    #counter input[type="text"]{display:inline-block;height:32px;padding:0;margin:0;border:0;outline:none;width:60px;text-align:center;font-size:22px;border-radius:2px}
  </style>
</head>
<body>
  <div id="counter">
    <button @click="subtract">-</button>
    <input type="text" v-model="count">
    <button @click="add">+</button>
  </div>
</body>
<script>
  new Vue({
    el: '#counter',
    data: {count: 12},
    methods: {
      add() {
        this.count++;
      },
      subtract() {
        this.count--;
      }
    }
  });
</script>
</html>